from selenium.webdriver.common.by import By
from Test_baidu_web.Base.Base import Base



class Page(Base):
    # 百度网址
    url = 'https://www.baidu.com/'
    # 搜索框
    search_input = (By.ID,'kw')
    # 点击搜索
    button_search = (By.ID,'su')
    # 第一个页面的网站
    address_1 = (By.XPATH , '//*[@id="3001"]/div/div/div/div[1]/h3/div/a')
    address_2 = (By.XPATH, '//*[@id="1"]/div/div/div/div[1]/div/h3/a/div/div/p/span/span/span')
    address_3 = (By.XPATH,'//*[@id="2"]/div/div/div/div[1]/div/h3/a/div/div/p/span/span/span')
    address_4 = (By.XPATH,'//*[@id="3"]/div/div/div/div[1]/div/h3/a/div/div/p/span/span/span')
    page_2 = (By.XPATH,'//*[@id="page"]/div/a[1]/span')

    #  搜索返回的网址
    address_21 = (By.XPATH,'//*[@id="3001"]/div/div/div/div[1]/h3/div/a')
    address_22 = (By.XPATH,'//*[@id="11"]/div/div/div/div[1]/div/h3/a/div/div/p/span/span/span')
    address_23 = (By.XPATH,'//*[@id="content_left"]/div[4]/div/div/div/div/div[1]/div/div/h3/div/a')
    address_24 = (By.XPATH,'//*[@id="13"]/div/div/h3/a')

    # 打开百度网站
    def url_open(self):
        self.get_url(self.url)

    #   输入框输入内容
    def send_test_search(self):
        self.send_keys(self.search_input,'我喜欢软件测试')
    #  点击搜索按钮
    def click_search_button(self):
        self.click(self.button_search)
    #  获取文本
    def get_address1(self):
        return self.get_text(self.address_1)
    #  获取文本
    def get_address2(self):
        return self.get_text(self.address_2)
    #  获取文本
    def get_address3(self):
        return self.get_text(self.address_3)
    #  获取文本
    def get_address4(self):
        return self.get_text(self.address_4)
    #  获取文本
    def get_address6(self):
        return self.get_text(self.address_21)
    #  获取文本
    def get_address7(self):
        return self.get_text(self.address_22)
    #  获取文本
    def get_address8(self):
        return self.get_text(self.address_23)
    #  获取文本
    def get_address9(self):
        return self.get_text(self.address_24)
    #   翻页
    def click_change_page(self):
        self.click(self.page_2)
    def title(self):
        return self.get_title()





